package com.zerui.manager.app.openplan.executer;

import com.alibaba.cola.catchlog.CatchAndLog;
import com.zerui.cola.dto.Response;
import com.zerui.manager.openplan.OpenPlan;
import com.zerui.manager.openplan.gateway.OpenPlanGateWay;
import com.zerui.manager.web.cmd.OpenPlanAddCmd;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.time.LocalDateTime;

/**
 * @author wh
 * @title: OpenPlanAddCmdExe
 * @description:
 * @date 2023/5/05 9:42
 */
@Component
@CatchAndLog
public class OpenPlanAddCmdExe {

	@Resource
	private OpenPlanGateWay openPlanGateWay;

	public Response execute(OpenPlanAddCmd cmd) {

		return openPlanGateWay.addOpenPlan(OpenPlan.builder()
				.accept(false)
				.endDate(cmd.getEndDate())
				.endTime(cmd.getEndTime())
				.name(cmd.getName())
				.remark(cmd.getRemark())
				.startDate(cmd.getStartDate())
				.startTime(cmd.getStartTime())
				.weekend(cmd.getWeekend())
				.createTime(LocalDateTime.now())
				.build());
	}
}
